<script>
	import chat from "@/libs/chat.js";
	import {
		versionUpgrade,
		getAppVersion
	} from "@/api/common.js";
	import {
		getWaitTotal
	} from "@/api/workFlow/flowBefore";
	import define from "@/utils/define.js"
	export default {
		data() {
			return {
				IntervalId: null,
			};
		},
		onLaunch: function() {
			// #ifdef H5
			const token = uni.getStorageSync("token");
			if (!token) return;
			chat.initSocket();
			// #endif
		},
		onShow: function() {
			// console.log('define', define);
			//#ifdef APP-PLUS
			this.jnpf.init();
			if (this.IntervalId) {
				clearInterval(this.IntervalId);
				// 将IntervalId设置为null，以避免潜在的内存泄漏或重复清除
				this.IntervalId = null;
			}
			//#endif
		},
		onHide: function() {
			//#ifdef APP-PLUS
			this.IntervalId = setInterval(() => {
				plus.push.clear();
				getWaitTotal().then((res) => {
					let Num = res.data;
					console.log(`Num:${Num}`);
					if (Num > 0) {
						this.jnpf.create(
							`点击查看`, {
								url: "/pages/workFlow/flowTodo/index",
							}, {
								delay: 0,
								title: `您有${Num}条待办事宜`,
							},
							true,
							Num
						);
					} else {
						plus.push.clear();
					}
				});
			}, 1000 * 60 * 5);
			//#endif
		},
		methods: {},
	};
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "@/uview-ui/index.scss";
	@import "@/uview-ui/demo.scss";
	@import "@/assets/iconfont/ym/iconfont.css";
	@import "@/assets/iconfont/custom/iconfont.css";
	@import "@/assets/scss/common.scss";
</style>